<extend name="Base/common"/>
<block name="header">
</block>
<block name="body">
    <div class="content-wrap">
        <div class="page-content">
            <div class="column">
                 <div class="column">
                    <div class="view-wrap">
                        <div class="view-title">
                            <h1>{$info.title}</h1>
                        </div>
                            <p style="line-height:30px;font-size:14px;text-align: center;">价格：<span style="color:red;font-size:18px;">{$info.price}</span>元</P>
						                  {$info.content}

                    </div>

                 </div>
            </div>

        </div>
<div class="view-buy-wrap fixed-wrap">  <table class="has-goods" border="0" cellspacing="0" cellpadding="0" ng-show="vo.kucun"> <tbody> <tr> <td class="subtotal">小计：<i  role="total">{$cartinfo['total']}</i>元</td> <td><span class="add" data-id="{$info.id}"></span></td> <td><span class="num" role="num">{$cartinfo['num']}</span></td> <td><span class="minus  sub" data-id="{$info.id}" ></span></td> </tr> </tbody> </table>   </div>

        <div class="bottom-nav" style="z-index: 9999;">
			<div class="open-nav"><p><a href="{:U('Index/indx')}" style="color:#444444;line-height:43px;">商城</a></p></div>
            <div class="shopcar">
				<if condition="$sum neq ''">
				<a href="{:U('Cart/index')}"><i id="cartnum"><span>{$sum}</span></i><small id="js">去结算 ¥{$allprice}</small></a>
				<else />
				<a href="javascript:;"><i id="cartnum"><span>0</span></i><small id="js">请选择水果</small></a>
				</if>

            </div>
        </div>



    </div><!-- /content-wrap -->
    <div id="animate"> <img id="cart-img" src="" width="100%" title="产品缩略图"> <div id="cart"><img src="http://m.bingofresh.com/v3.5/ui/images/cart.png?v=3" width="100%" title="购物车"></div> </div>

</block>

<block name="script">
<script>
$(function(){
$(".add").click(function(){
    var $this = $(this),
        good_id  = $this.attr('data-id'),
        url    = '{:U("cart/addcart")}',
        $num = $this.parents('table').find('[role="num"]'),
        $total = $this.parents('table').find('[role="total"]');

    $.post(url, {id:good_id}, function(data){
		if(data.status==1){
			$('#cartnum span').text(data.sum);
			$num.text(data.num);
			$total.text(data.total)
			$("#js").text("去结算 ¥"+data['allprice'])
			$("#js").parent().attr('href',"{:U('Cart/index')}")
			$(".minus").addClass(".sub").removeClass('forbidden');
		}else{
			alert(data.info);
		}
    })
})
$(".sub").click(function(){
    var $this = $(this),
        good_id  = $this.attr('data-id'),
        url    = '{:U("cart/deletecart")}',
        $num = $this.parents('table').find('[role="num"]'),
        $total = $this.parents('table').find('[role="total"]');
    $.post(url, {id:good_id}, function(data){
		if(data.status==1){
			$('#cartnum span').text(data.sum);
			$num.text(data.num);
			$total.text(data.total)
			$("#js").text("去结算 ¥"+data['allprice'])
			if(data.num == 0){
				$num.text("0");
				$total.text("0");
				$this.removeClass('.sub').addClass('forbidden')
			}
		}else{
			$num.text("0");
			$total.text("0");
			$this.removeClass('.sub').addClass('forbidden')
			$('#cartnum span').text("0");
			$("#js").text("请选择水果！");
			$("#js").parent().attr('href',"javascript:;")
		}


    })
})

$('[data-dismiss="buy"]').click(function(){
    var query = $(this).parents(".info").find('input').serialize();
    var url = $(this).attr('data-url');
    $.post(url, query, function(data){
        if(data.status == 1){
             location.href=data.url;
        }else{
            alert(data.info);
        }
    });
})

})
</script>
</block>
